using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DAL;
using BUS;
using Entities;
using Utility;

public partial class Admin_TrangThaiDonHangList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadData();
        }

    }
    private void LoadData()
    {
        Criteria cri = new Criteria();
        int total = 0;
        if (txt_idttdh.Text != "")
        {
            cri.add(Condition.AND, tbTTDonHang .tbTTDonHangColumns .TrangThaiDH .ToString(), Condition.LIKE, txt_tttdh.Text);
        }
        tbTTDonHang .tbTTDonHangCollection  ttdhcollection = tbTTDonHangBus .Get(cri.Criter, Pager.CurrentIndex, Pager.PageSize, tbTTDonHang .tbTTDonHangColumns .IDTTDonHang .ToString(), OrderDirection.ASC.ToString(), out total);
        Repeater1.DataSource = ttdhcollection;
        Repeater1.DataBind();
        Pager.ItemCount = total;
    }
    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem ||
            e.Item.ItemType == ListItemType.Item)
        {
            tbTTDonHang  ttdh = (tbTTDonHang )e.Item.DataItem;
            HyperLink hyp_ttdh = (HyperLink)e.Item.FindControl("hyp_ttdh");

            Literal lit_mttdh = (Literal)e.Item.FindControl("lit_mttdh");
            HiddenField hf_id = (HiddenField)e.Item.FindControl("hf_id");


            lit_mttdh.Text = ttdh.IDTTDonHang.ToString();
            hf_id.Value = ttdh.IDTTDonHang.ToString();

            hyp_ttdh.Text = ttdh.TrangThaiDH .ToString();


            hyp_ttdh.NavigateUrl = "TrangThaiDonHangList.aspx";


            HyperLink hpl_Edit = (HyperLink)e.Item.FindControl("hpl_Edit");
            hpl_Edit.NavigateUrl = "TrangThaiDonHangUpdate.aspx?id=" + ttdh.IDTTDonHang.ToString();


        }

    }
    protected void Pager_Command(object sender, CommandEventArgs e)
    {
        Pager.CurrentIndex = int.Parse(e.CommandArgument.ToString());
        LoadData();
    }
    protected void btn_Search_Click(object sender, EventArgs e)
    {
        LoadData();
    }
}
